﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PaintEstimate
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Pseudocode for this program:
             * input total square feet of area to be painted
             * paintNeeded = totalArea / 115
             * timeNeeded = totalArea / 14.375(115/8)
             * display total amount of paint to be used
             * input price per gallon of paint
             * paintPrice = paintNeeded * galonPrice
             * workPrice = timeNeeded * 20
             * totalCost = paintPrice + workPrice
             * display job information and pricing
             * END Program or Loop it
             */
            string loop = "Y";
            double totalArea = 0, paintNeeded = 0, timeNeeded = 0, paintPrice = 0, paintCost = 0, workPrice = 0, totalPrice = 0;
            while (loop.ToUpper() == "Y")
            {
                print("Paint Job cost estimator");
                getTotalArea(ref totalArea,ref paintNeeded);
                getPaintPrice(ref paintPrice,ref paintCost,paintNeeded);
                calculateCost(ref workPrice,ref totalPrice,paintPrice,paintCost,ref timeNeeded,paintNeeded,totalArea);

                print("Type Y to estimate another Paint Job or any other key to end the program");
                loop = Console.ReadLine();
            }
        }
        static void getTotalArea(ref double totalArea, ref double paintNeeded)
        {
            Console.WriteLine("For this area you need a total of {0} galons of paint.", paintNeeded);
            print("please provide the total square feet that needs to be painted:");
            while (!double.TryParse(Console.ReadLine(), out totalArea))
            {
                print("The number you have provided is invalid, please try again.");
            }
            paintNeeded = totalArea / 115;
        }
        static void getPaintPrice(ref double paintPrice, ref double paintCost, double paintNeeded)
        {
            print("Please enter the price per galon of paint to be used for this project:");
            while (!double.TryParse(Console.ReadLine(), out paintCost))
            {
                print("The number you have provided is invalid, please try again.");
            }
            paintPrice = paintCost * paintNeeded;
        }
        static void calculateCost(ref double workPrice,ref double totalPrice,double paintPrice,double paintCost,ref double timeNeeded,double paintNeeded,double totalArea)
        {
            timeNeeded = totalArea / 14.375;
            workPrice = 20 * timeNeeded;
            totalPrice = paintPrice + workPrice;
            Console.WriteLine("The total price of this project is ${0}, for a total of:\n{1} square feed that need to be painted with:\n{2} gallon(s) of paint that costs: ${3} per gallon, time needed is:\n{4} Hours for a rate of $20.00 per hour",totalPrice,totalArea,paintNeeded,paintCost,timeNeeded);
        }
        static void print(string text)
        {
            Console.WriteLine("\n{0}", text);
        }
    }
}
